# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=swhkd
pkgver=1.2.1
pkgrel=0
pkgdesc="Sxhkd clone for Wayland (works on TTY and X11 too)"
url="https://git.sr.ht/~shinyzenith/swhkd"
# s390x, loongarch64: build fails on nix dependency
arch="all !s390x !loongarch64"
license="BSD-2-Clause"
depends="polkit"
makedepends="cargo scdoc cargo-auditable"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~shinyzenith/swhkd/archive/$pkgver.tar.gz
	lock.patch
	libc.patch
	"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen --bins
	mkdir -p man/man5
	mkdir -p man/man1

	scdoc < ./docs/swhkd.1.scd > man/man1/swhkd.1
	scdoc < ./docs/swhkd.5.scd > man/man5/swhkd.5
	scdoc < ./docs/swhkd-keys.5.scd > man/man5/swhkd-keys.5
	scdoc < ./docs/swhks.1.scd > man/man1/swhks.1
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/swhkd target/release/swhks \
		-t "$pkgdir"/usr/bin/

	install -Dm644 com.github.swhkd.pkexec.policy \
		-t "$pkgdir"/usr/share/polkit-1/actions/

	cp -a man "$pkgdir"/usr/share/man
}

sha512sums="
2c67c2a818a605312eef19cdb7444c5d10a5d06abb3c7df4236a6b70a4917a0da3d7bdfe05cfbb8c95123b3321d91edc72d50cd3af5a59459a40c9e5cfb0f027  swhkd-1.2.1.tar.gz
2fad72df67c831119ef630b5f1fb9fd5a90b22af115c11196117dd1774cc47e64c8eb10f48c0d64c6105459def32c2907c07ff96b31670997a085f97e9b8b9af  lock.patch
1de0bc863aa8e9739407bac4e11303f43e17ad56c34b1d7ec27776652bcd7671f46c416fb121ac0dea0915f2d0c9fa4339bb0410b41d5d4ce467769744f4520e  libc.patch
"
